package com.jddup.program.dao.sqlbuilder.postgresql;

import com.jddup.program.dao.sqlbuilder.QueryPrepareSQLBuilder;

/**
 * Created by ZZB on 2017/10/22.
 */
public class PostgresqlQueryPrepareSQLBuilder implements QueryPrepareSQLBuilder {
	private static final String QUERY_BY_FIELD_SQL = "SELECT * from {tableName} where {fieldName} = ?";
	private static final String COUNT_BY_FIELD_SQL = "SELECT count(*) from {tableName} where {fieldName} = ?";

	@Override
	public String queryByFieldSQL(String tableName, String field) {
		return QUERY_BY_FIELD_SQL.replace("{tableName}", tableName).replace("{fieldName}", "\"" + field + "\"");
	}

	@Override
	public String countByFieldSQL(String tableName, String field) {
		return COUNT_BY_FIELD_SQL.replace("{tableName}", tableName).replace("{fieldName}", "\"" + field + "\"");
	}

}
